package com.wx.gof.pattern.creational.singleton;

/**
 * @ClassName Application
 * @Author wx
 * @Description 单例模式-懒汉(synchronized锁,性能低)
 * @Date 2018-12-04
 */
public class LazySingleton {
    private static LazySingleton lazySingleton = null;
    private LazySingleton(){
        if(lazySingleton != null){
            throw new RuntimeException("单例构造器禁止反射调用");
        }
    }
    public synchronized static LazySingleton getInstance(){
        if(lazySingleton == null){
            lazySingleton = new LazySingleton();
        }
        return lazySingleton;
    }

}
